beginoutdoorscript;

variables;

int choice;

body;

beginstate INIT_STATE;
// This state called whenever this section is loaded into memory.
break;

beginstate START_STATE;
if (get_flag(150,0) != 0)
        eliminate_outdoor_enc(150,0);
break;

beginstate 10;
        reset_dialog();
        add_dialog_str(0,"There is a farm here, along with several sets of crops. This must be where Schowor gets it's food from.",0);
        if (get_flag(150,0) == 0)
        add_dialog_str(1,"You approach, but they don't let you in. Given the current trouble with the Nephilim, they're not taking any chances.",0);
        if (get_flag(150,0) != 0)
        add_dialog_str(1,"You approach, and talk to them a bit. They say they don't have any extra food to spare, but you can buy some from Aldnala in Schowor.",0);
        add_dialog_choice(0,"OK.");
        run_dialog(1);
break;

beginstate 11;
        reset_dialog();
        add_dialog_str(0,"There is a hut out here.",0);
        add_dialog_choice(0,"Knock on the door.");
        add_dialog_choice(1,"Leave.");
        choice = run_dialog(1);
        if (choice == 1) {
                if (get_flag(0,0) != 1)
                        set_state_continue(12);
                if (get_flag(0,0) == 1)
                        set_state_continue(14);
                }
        if (choice == 2)
                end();
break;
beginstate 12;
        reset_dialog();
        add_dialog_str(0,"You knock on the door. There are several people inside, who are working hard on making potions.",0);
        add_dialog_str(1,"One of them offers to sell you some.",0);
        add_dialog_choice(0,"Buy some potions.");
        add_dialog_choice(1,"Leave.");
        choice = run_dialog(1);
        if (choice == 1)
                set_state_continue(13);
        if (choice == 2)
                end();
break;
beginstate 13;
begin_shop_mode("Potion shop","This person has a variery of potions available for sale.",4,3,-1);
end();
break;
beginstate 14;
        reset_dialog();
        add_dialog_str(0,"You knock on the door. There are several people inside, who are working hard on making potions.",0);
        add_dialog_str(1,"One of them offers to sell you some.",0);
        add_dialog_str(3,"During the conversation, you ask about Doust. The person you're talking to says that they hired Doust to help with the potions, and that he's doing fine. He'll be busy for the next few weeks, however.",0);
        add_dialog_choice(0,"Buy some potions.");
        add_dialog_choice(1,"Leave.");
        set_flag(0,0,2);
        choice = run_dialog(1);
        if (choice == 1)
                set_state_continue(13);
        if (choice == 2)
                end();
break;

beginstate 15;
        reset_dialog();
        add_dialog_str(0,"There is a hut out here.",0);
        add_dialog_choice(0,"Knock on the door.");
        add_dialog_choice(1,"Leave.");
        choice = run_dialog(1);
        if (choice == 1) {
                if ((get_flag(150,0) == 0) && (get_flag(100,0) == 0)) {
                        message_dialog("You knock on the door. The hut contains a group of nephilim, who attack you immediately.","");
                        create_out_spec_enc(0);
                }
                if ((get_flag(150,0) == 1) || (get_flag(100,0) == 1)) {
                        message_dialog("You knock on the door. There is no response. The hut is empty","");
                        set_flag(100,0,1);
                }
                }
        if (choice == 2)
                end();
break;

beginstate 17;
if (get_flag(100,1) == 0) {
                reset_dialog();
                add_dialog_str(0,"As you approach this building, you suddenly feel unsure of yourself.",0);
                add_dialog_str(1,"It appears that something nearby is interfering with your ability to fight effectively.",0);
                add_dialog_str(2,"You barely notice the troglodytes charging out of the building.",0);
                add_dialog_choice(0,"OK.");
                run_dialog(1);
                alter_stat(0,31,12);
                alter_stat(1,31,12);
                alter_stat(2,31,12);
                alter_stat(3,31,12);
                create_out_spec_enc(1);
                set_flag(100,1,1);
}
break;
beginstate 18;
if (get_flag(100,2) == 1) {
                reset_dialog();
                add_dialog_str(0,"The mithral bar and the gold is still here.",0);
                add_dialog_choice(0,"Take.");
                add_dialog_choice(1,"Leave.");
                choice = run_dialog(1);
        if (choice == 1) {
                set_flag(100,2,2);
                change_coins(450);
                change_spec_item(2,1);
                end();
                }
        if (choice == 2)
                end();
                }
if (get_flag(100,2) == 0) {
                reset_dialog();
                add_dialog_str(0,"You finally arrive at the building. Searching it thoroughly, you find a crystal.",0);
                add_dialog_str(1,"This crystal is radiating a magical field, and must be what was interfering with your ability to fight.",0);
                add_dialog_str(2,"You smash the crystal with one of your weapons, and the magical field immediately ceases.",0);
                add_dialog_str(3,"There is a mithral bar inside the building as well as some gold.",0);
                add_dialog_choice(0,"Take.");
                add_dialog_choice(1,"Leave.");
                alter_stat(0,31,-12);
                alter_stat(1,31,-12);
                alter_stat(2,31,-12);
                alter_stat(3,31,-12);
                set_flag(100,2,1);
                choice = run_dialog(1);
        if (choice == 1) {
                set_flag(100,2,2);
                change_coins(450);
                change_spec_item(2,1);
                end();
                }
        if (choice == 2)
                end();
                }
break;

beginstate 19;
                if ((get_flag(100,3) == 0) && (get_ran(1,1,100) < 11)) {
                reset_dialog();
                add_dialog_str(0,"One of the nephilim was carrying a mithral bar. You decide that this bar may be useful later, and take it with you.",0);
                change_spec_item(2,1);
                set_flag(100,3,1);
                run_dialog(1);
                }
break;

beginstate 20;
                reset_dialog();
                add_dialog_str(0,"The nepharim chief had a scroll in his pack. You recognize the language: it's Vahnatai. You can't translate the message, however.",0);
                set_flag(100,5,1);
                change_spec_item(0,1);
                run_dialog(1);
break;

beginstate 21;
reset_dialog();
add_dialog_str(0,"There is a hut out here.",0);
add_dialog_choice(0,"Knock on the door.");
add_dialog_choice(1,"Leave.");
choice = run_dialog(1);
if (choice == 1) {
if ((get_flag(100,5) != 2) && (get_flag(150,1) != 1)) {
reset_dialog();
add_dialog_str(0,"A hermit answers the door. He seems glad to have a visitor. You engage in small talk for a few minutes before you leave.",0);
run_dialog(1);
end();
}
if ((get_flag(150,1) == 1) && (get_flag(100,5) != 2)) {
reset_dialog();
add_dialog_str(0,"A hermit answers the door. He seems glad to have a visitor. You engage in small talk for a few minutes.",0);
add_dialog_str(1,"During the conversation, you mention that you'd have a scroll which needs to be translated. He agrees to translate it, and looks at it for about twelve minutes.",0);
add_dialog_str(3,"The scroll is a message from Rentar-Ihrno. It reads as follows...",0);
set_flag(150,1,2);
run_dialog(1);
reset_dialog();
add_dialog_str(0,"Our army is nearly ready, and will be finished in a few months. You've made good progress.",0);
add_dialog_str(1,"The Empire has asked a group of adventurers(probably you) to investigate the problem. Be prepared for them.",0);
add_dialog_str(2,"Even if they manage to defeat you and halt this experiment, it has already gotten enough success.",0);
add_dialog_str(3,"We should soon have our revenge on the Empire.",0);
add_dialog_str(5,"This does not look good.",0);
run_dialog(1);
}
if (get_flag(100,5) == 2) {
reset_dialog();
add_dialog_str(0,"A hermit answers the door. He seems glad to have a visitor. You engage in small talk for a few minutes.",0);
add_dialog_str(1,"During the conversation, you mention that you'd have a scroll which needs to be translated. He agrees to translate it, and looks at it for a few minutes.",0);
add_dialog_str(3,"The scroll says that there is a nephilim base on a hill to the southeast, which has two defensive walls.",0);
add_dialog_str(4,"You can get past the first wall by casting Move Mountains on one of the southwest walls, and the second wall has a secret passage in the southwest corner.",0);
add_dialog_str(5,"You thank him for the information and leave.",0);
set_flag(100,5,3);
set_town_visibility(1,1);
run_dialog(1);
}
}
if (choice == 2)
end();
break;

beginstate 22;
        reset_dialog();
        add_dialog_str(0,"You have reached the edge of the Querbel valley; it's only a short hike to the next city. If you've done all you want, you can leave the valley.",0);
        add_dialog_choice(0,"Stay in the valley.");
        add_dialog_choice(1,"Leave the valley.");
        choice = run_dialog(1);
        if (choice == 1)
                end();
        if (choice == 2)
                reset_dialog();
                if ((get_flag(150,0) == 0)) {
                        add_dialog_str(0,"You depart the valley. Shortly after completing your journey, you report to the Empire commander that you didn't succeed in your mission.",0);
                        add_dialog_str(1,"She's upset with you over your failure, and refuses to talk with you any more.",0);
                        add_dialog_str(2,"Needless to say, you don't get any reward.",0);
                        run_dialog(0);
                        end_scenario(0);
                }
                if ((get_flag(150,0) != 0) && (get_flag(150,1) != 2)) {
                        add_dialog_str(0,"You depart the valley. Shortly after completing your journey, you report to the Empire commander that you succeeded in your mission.",0);
                        add_dialog_str(1,"She's glad that you succeeded, and gives you 2000 gold.",0);
                        add_dialog_str(2,"However, you have an odd feeling about the situation. Something about it doesn't seem right.",0);
                        run_dialog(0);
                        change_coins(2000);
                        award_party_xp(800,70);
                        end_scenario(1);
                }
                if ((get_flag(150,0) != 0) && (get_flag(150,1) == 2)) {
                        add_dialog_str(0,"You depart the valley. Shortly after completing your journey, you report to the Empire commander that you succeeded in your mission.",0);
                        add_dialog_str(1,"You also report the content of the second scroll you found, and she becomes alarmed.",0);
                        add_dialog_str(2,"She orders someone to tell Empress Prazac what you found, and the Empire soon begins to plan a defence.",0);
                        add_dialog_str(3,"You are paid 2000 gold for your efforts, but realize that you may be called back.",0);
                        run_dialog(0);
                        change_coins(2000);
                        award_party_xp(800,70);
                        end_scenario(1);
                }
break;

beginstate 23;
        reset_dialog();
        add_dialog_str(0,"There is a building out here.",0);
        add_dialog_choice(0,"Knock on the door.");
        add_dialog_choice(1,"Leave.");
        choice = run_dialog(1);
        if (choice == 1) {
                reset_dialog();
                add_dialog_str(0,"A friendly merchant greets you. He enthusiastically tries to get you to purchase some scrolls.",0);
                add_dialog_choice(0,"Buy some scrolls.");
                add_dialog_choice(1,"Leave.");
                choice = run_dialog(1);
                        if (choice == 1) {
                                begin_shop_mode("Scroll shop","This person is selling a number of different scrolls, all of which may be useful.",9,3,-1);
                                end();
                }
                        if (choice == 2)
                                end();
        if (choice == 2)
                end();
        }
break;

beginstate 24;
if (get_flag(160,0) == 5) {
        reset_dialog();
        add_dialog_str(0,"There is a hut out here.",0);
        add_dialog_choice(0,"Knock on the door.");
        add_dialog_choice(1,"Leave.");
        choice = run_dialog(1);
        if (choice == 1) {
                reset_dialog();
                add_dialog_str(0,"There is no response. The hut is probably empty.",0);
                add_dialog_str(1,"Unfortunately, some invisible monsters had set a trap, which you fell into.",0);
                add_dialog_str(2,"They blast you with spells, and then proceed to attack.",0);
                add_dialog_choice(0,"OK.");
                run_dialog(1);
                set_party_status(1,-15,0);
                set_party_status(2,-15,0);
                set_party_status(3,-15,0);
                set_party_status(11,5,0);
                set_party_status(13,1,0);
                create_out_spec_enc(2);
        }
        if (choice == 2)
                end();
        }
break;

beginstate 25;
if (get_flag(160,1) == 0) {
        reset_dialog();
        add_dialog_str(0,"There is a hut out here.",0);
        add_dialog_choice(0,"Knock on the door.");
        add_dialog_choice(1,"Leave.");
        choice = run_dialog(1);
        if (choice == 1) {
                reset_dialog();
                add_dialog_str(0,"An angry hermit storms out of the hut. She screams at you for disrupting her solitude, and then points at you.",0);
                add_dialog_str(1,"You suddenly find yourself somewhere else.",0);
                add_dialog_choice(0,"OK.");
                run_dialog(1);
                set_flag(160,1,2);
                out_move_party(39,12);
        }
        if (choice == 2)
                end();
        }
if (get_flag(160,1) == 1) {
        reset_dialog();
        add_dialog_str(0,"You approach the hut you tried to visit earlier. Remembering what happened last time, you don't knock on the door again.",0);
        run_dialog(1);
        end();
        }
if (get_flag(160,1) == 2)
        set_flag(160,1,1);
break;

beginstate 26;
        reset_dialog();
        add_dialog_str(0,"There is a hut out here. The front door is off its hinges, and the hut seems to have been damaged.",0);
        add_dialog_choice(0,"Enter.");
        add_dialog_choice(1,"Leave.");
        choice = run_dialog(1);
        if (choice == 1) {
                reset_dialog();
                add_dialog_str(0,"This hut has been ransacked. Everything of value has been taken, and most of what's left has been smashed.",0);
//                        if (get_flag(150,0) == 1) && (get_flag(100,3) ==0); {
//                        add_dialog_str(1,"While searching it, you come across a mithral bar, which you take. You don't find anything else worth having.",0);
//                        change_spec_item(2,1);
//                        set_flag(100,3,1);
//                        else
                add_dialog_str(1,"After spending a while searching it, you find nothing worth having. You leave.",0);
        }
                add_dialog_choice(0,"OK.");
                run_dialog(1);
        if (choice == 2)
                end();
break;